<?php
// +----------------------------------------------------------------------
// | 众联TK架构 [ ZoomTk ]
// +----------------------------------------------------------------------
// | 版权所有 2017~2037 成都众联思索科技有限公司 [ http://www.zoomtk.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://www.sopvip.com
// +----------------------------------------------------------------------
// | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

namespace app\mall\admin;
use app\common\builder\TKuitpl;
use app\mall\common\Adminbase;
use think\Model;
use think\Cache;
use think\Db;

/**
 * 商家管理中心
 * @package app\mall\admin
 */
class Type extends Adminbase
{
    /**
     * 首页
     * @author Sunday <153788231@qq.com>
     * @return mixed
     */
    public function index()
    {
        $map = $this->getMap();
        $type_list = Model('type')->typeList($map);
        $page= $type_list->render();
        foreach ($type_list as $value) {
            $param = array();
           // $operation = "<a class='btn red' href='javascript:void(0);' onclick='fg_del(". $value['type_id'] .")'><i class='fa fa-trash-o'></i>删除</a><a class='btn blue' href='index.php?s=type&op=type_edit&t_id=".$value['type_id']."'><i class='fa fa-pencil-square-o'></i>编辑</a>";
          //  $param['operation'] = $operation;
            $param['type_id'] = $value['type_id'];
            $param['type_name'] = $value['type_name'];
            $param['type_sort'] = $value['type_sort'];
            $param['class_id'] = $value['class_id'];
            $param['class_name'] = $value['class_name'];
            $data[$value['type_id']] = $param;
        }
        // 使用TKuitpl快速创建数据表格
        return TKuitpl::make('table')
            ->setPageTitle('类型管理')// 设置页面标题
            ->addTopButtons('add') // 批量添加顶部按钮
            ->addTopButtons('delete') // 批量添加顶部按钮
            ->setPrimaryKey('type_id') // 设置主键名为username
            ->setSearch(['type_id' => '类型ID', 'type_name' => '类型名称'])// 设置搜索参数
            ->addOrder('type_id,type_name') // 添加排序
            ->addColumns([ // 批量添加列
                ['type_id', '类型ID'],
                ['type_name', '类型名称'],
                ['type_sort', '类型排序'],
                ['class_id', '快捷定位ID'],
                ['class_name', '定位名称'],
                ['right_button', '操作', 'btn']
            ])
            ->addRightButtons('edit,delete')// 批量添加右侧按钮
            ->setRowList($data)// 设置表格数据
            ->setPages($page)// 设置分页数据
            ->fetch(); // 渲染页面
    }
}


